﻿@using Orchard.UI.Resources;
@functions {
    // To support the layout classifaction below. Implementing as a razor function because we can, could otherwise be a Func<string[], string, string> in the code block following.
    string CalcuClassify(string[] zoneNames, string classNamePrefix)
    {
        var zoneCounter = 0;
        var zoneNumsFilled = string.Join("", zoneNames.Select(zoneName => { ++zoneCounter; return Model[zoneName] != null ? zoneCounter.ToString() : ""; }).ToArray());
        return HasText(zoneNumsFilled) ? classNamePrefix + zoneNumsFilled : "";
    }
}
@{
    /* Global includes for the theme
    ***************************************************************/

    // SetMeta("charset", "utf-8");
    // SetMeta("X-UA-Compatible", "IE=edge,chrome=1");
    SetMeta("viewport", "width=device-width, initial-scale=1.0");

    RegisterLink(new LinkEntry { Type = "image/x-icon", Rel = "shortcut icon", Href = Url.Content("~/themes/skautsis.center/content/skaut.ico") });

    Script.Include("bootstrap.js");
    Script.Include("custom.js");

    Style.Include("site.css");

    /* Some useful shortcuts or settings
    ***************************************************************/

    Func<dynamic, dynamic> Zone = x => Display(x); // Zone as an alias for Display to help make it obvious when we're displaying zones

    /* Layout classification based on filled zones
    ***************************************************************/

    //Add classes to the wrapper div to toggle aside widget zones on and off
    var asideClass = CalcuClassify(new[] { "AsideFirst", "AsideSecond" }, "aside-"); // for aside-1, aside-2 or aside-12 if any of the aside zones are filled
    if (HasText(asideClass))
    {
        Model.Classes.Add(asideClass);
    }

    //Add classes to the wrapper div to toggle tripel widget zones on and off
    var tripelClass = CalcuClassify(new[] { "TripelFirst", "TripelSecond", "TripelThird" }, "tripel-"); // for tripel-1, triple-2, etc. if any of the tripel zones are filled
    if (HasText(tripelClass))
    {
        Model.Classes.Add(tripelClass);
    }

    //Add classes to the wrapper div to toggle quad widget zones on and off
    var footerQuadClass = CalcuClassify(new[] { "FooterQuadFirst", "FooterQuadSecond", "FooterQuadThird", "FooterQuadFourth" }, "split-"); // for quad-1, quad-2, etc. if any of the quad zones are filled
    if (HasText(footerQuadClass))
    {
        Model.Classes.Add(footerQuadClass);
    }

    /* Inserting some ad hoc shapes
    ***************************************************************/

    WorkContext.Layout.UserPanel.Add(New.User(), "5"); // Login and dashboard links
    // WorkContext.Layout.Navigation.Add(New.SearchNav(), "10"); // Search box (requires Search module)

    /* Last bit of code to prep the layout wrapper
    ***************************************************************/

    Model.Id = "layout-wrapper";
    var tag = Tag(Model, "div"); // using Tag so the layout div gets the classes, id and other attributes added to the Model
}
<div id="layout-wrapper">

    <header id="header" class="hidden-print navbar navbar-default">
        <div class="container">
            <div class="row">

                <div id="brand" class="col-xs-6 col-sm-3">
                    @Zone(Model.Logo)
                </div>

                <div id="user-panel" class="col-xs-6 col-sm-offset-3 col-sm-3">
                    @Zone(Model.UserPanel)
                </div>

                <div id="site-switch" class="hidden-xs col-sm-3">
                    @Zone(Model.SiteSwitch)
                </div>

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    <span class="sr-only">Menu</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>

            <div class="row">

                <div class="col-xs-12 col-sm-9">
                    <div id="navigation-primary" class="collapse navbar-collapse navbar-ex1-collapse">
                        @Zone(Model.Navigation)
                    </div>
                </div>  

                <div id="join-button" class="hidden-xs col-sm-3">
                    @Zone(Model.JoinButton)
                </div>

            </div>

        </div>
    </header>

    @if (Model.Featured != null)
    {
        <section id="featured" class="hidden-print">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12">
                        @Zone(Model.Featured)
                    </div>
                </div>
            </div>
        </section>
    }

    <section id="content">
        <div class="container">
            @if (Model.BeforeMain != null)
            {
                <div class="row hidden-print">
                    <div class="col-xs-12">
                        @Zone(Model.BeforeMain)
                    </div>
                </div>
            }
            <div class="row">
                @if (Model.AsideFirst != null)
                {
                    <div class="aside hidden-print col-xs-12 @(Model.AsideSecond != null ? "col-sm-3" : "col-sm-4")">
                        @Zone(Model.AsideFirst)
                    </div>
                }
                <div class="col-xs-12 @(HasText(asideClass) ? (asideClass == "aside-1" || asideClass == "aside-2" ? "col-sm-8" : (asideClass == "aside-12" ? "col-sm-6" : "")) : "")">
                    @if (Model.Messages != null)
                    {
                        @Zone(Model.Messages)
                    }
                    @if (Model.BeforeContent != null)
                    {
                        @Zone(Model.BeforeContent)
                    }

                    @if (Model.Content != null)
                    {
                        @Zone(Model.Content)
                    }
                    @if (Model.AfterContent != null)
                    {
                        @Zone(Model.AfterContent)
                    }
                </div>
                @if (Model.AsideSecond != null)
                {
                    <aside class="aside hidden-print col-xs-12 @(Model.AsideFirst != null ? "col-sm-3" : "col-sm-4")">
                        @Zone(Model.AsideSecond)
                    </aside>
                }
            </div>
            @if (Model.AfterMain != null)
            {
                <div class="row hidden-print">
                    <div class="col-xs-12">
                        @Zone(Model.AfterMain)
                    </div>
                </div>
            }

            @if (Model.TripelFirst != null || Model.TripelSecond != null || Model.TripelThird != null)
            {
                <div class="row hidden-print">
                    @if (Model.TripelFirst != null)
                    {
                        <div class="col-xs-12 @(HasText(tripelClass) ? tripelClass == "tripel-12" || tripelClass == "tripel-23" || tripelClass == "tripel-13" ? "col-sm-6" : tripelClass == "tripel-123" ? "col-sm-4" : "col-12" : "col-12")">
                            @Zone(Model.TripelFirst)
                        </div>
                    }
                    @if (Model.TripelSecond != null)
                    {
                      
                        
                        <div class="col-xs-12 @(HasText(tripelClass) ? tripelClass == "tripel-12" || tripelClass == "tripel-23" || tripelClass == "tripel-13" ? "col-sm-6" : tripelClass == "tripel-123" ? "col-sm-4" : "col-12" : "col-12")">
                            @Zone(Model.TripelSecond)
                        </div>
                    }
                    @if (Model.TripelThird != null)
                    {
                        <div class="col-xs-12 @(HasText(tripelClass) ? tripelClass == "tripel-12" || tripelClass == "tripel-23" || tripelClass == "tripel-13" ? "col-sm-6" : tripelClass == "tripel-123" ? "col-sm-4" : "col-12" : "col-12")">
                            @Zone(Model.TripelThird)
                        </div>
                    }
                </div>
            }
            @if (Model.FooterQuadFirst != null || Model.FooterQuadSecond != null || Model.FooterQuadThird != null || Model.FooterQuadFourth != null)
            {
                <hr />
                <div class="row hidden-print">
                    @if (Model.FooterQuadFirst != null)
                    {
                        <div class="col-xs-12 @(HasText(footerQuadClass) ? footerQuadClass == "split-1" || footerQuadClass == "split-2" || footerQuadClass == "split-3" || footerQuadClass == "split-4" ? "" : footerQuadClass == "split-12" || footerQuadClass == "split-13" || footerQuadClass == "split-14" || footerQuadClass == "split-23" || footerQuadClass == "split-24" || footerQuadClass == "split-34" ? "col-sm-6" : footerQuadClass == "split-123" || footerQuadClass == "split-124" || footerQuadClass == "split-134" || footerQuadClass == "split-234" ? "col-sm-4" : "col-sm-6 col-lg-3" : "")">
                            @Zone(Model.FooterQuadFirst)
                        </div>
                    }
                    @if (Model.FooterQuadSecond != null)
                    {
                        <div class="col-xs-12 @(HasText(footerQuadClass) ? footerQuadClass == "split-1" || footerQuadClass == "split-2" || footerQuadClass == "split-3" || footerQuadClass == "split-4" ? "" : footerQuadClass == "split-12" || footerQuadClass == "split-13" || footerQuadClass == "split-14" || footerQuadClass == "split-23" || footerQuadClass == "split-24" || footerQuadClass == "split-34" ? "col-sm-6" : footerQuadClass == "split-123" || footerQuadClass == "split-124" || footerQuadClass == "split-134" || footerQuadClass == "split-234" ? "col-sm-4" : "col-sm-6 col-lg-3" : "")">
                            @Zone(Model.FooterQuadSecond)
                        </div>
                    }
                    @if (Model.FooterQuadThird != null)
                    {
                        <div class="col-xs-12 @(HasText(footerQuadClass) ? footerQuadClass == "split-1" || footerQuadClass == "split-2" || footerQuadClass == "split-3" || footerQuadClass == "split-4" ? "" : footerQuadClass == "split-12" || footerQuadClass == "split-13" || footerQuadClass == "split-14" || footerQuadClass == "split-23" || footerQuadClass == "split-24" || footerQuadClass == "split-34" ? "col-sm-6" : footerQuadClass == "split-123" || footerQuadClass == "split-124" || footerQuadClass == "split-134" || footerQuadClass == "split-234" ? "col-sm-4" : "col-sm-6 col-lg-3" : "")">
                            @Zone(Model.FooterQuadThird)
                        </div>
                    }
                    @if (Model.FooterQuadFourth != null)
                    {
                        <div class="col-xs-12 @(HasText(footerQuadClass) ? footerQuadClass == "split-1" || footerQuadClass == "split-2" || footerQuadClass == "split-3" || footerQuadClass == "split-4" ? "" : footerQuadClass == "split-12" || footerQuadClass == "split-13" || footerQuadClass == "split-14" || footerQuadClass == "split-23" || footerQuadClass == "split-24" || footerQuadClass == "split-34" ? "col-sm-6" : footerQuadClass == "split-123" || footerQuadClass == "split-124" || footerQuadClass == "split-134" || footerQuadClass == "split-234" ? "col-sm-4" : "col-sm-6 col-lg-3" : "")">
                            @Zone(Model.FooterQuadFourth)
                        </div>
                    }
                </div>
            }
        </div>
    </section>
</div>

<footer id="footer">
    <div class="container">
        <div class="row">
            <div class="hidden-print col-xs-2 col-sm-1">
                <a href="http://www.skaut.cz" title="Oficiální stránky organizace Junák &ndash; svaz skautů a skuatek ČR"><img class="img-responsive" src="@Url.Content("~/Themes/SkautSIS.Center/Content/logo-skaut-neg.png")" alt="Logo Skaut" /></a>
            </div>
            <div class="col-xs-10 col-sm-11">
                <div class="row">
                    <div class="pull-right">
                        @Zone(Model.FooterCopyright)
                    </div>
                </div>
                <div class="row hidden-print">
                    <div class="pull-right">
                        @Zone(Model.FooterNavigation)
                    </div>
                </div>
            </div>
        </div>
    </div>
</footer>